//
//  PQHttp.h
//  Traiana Harmony
//
//  Created by Barak Edry on 7/26/12.
//
//

#import <Foundation/Foundation.h>

typedef void (^QPResponseCallback)(NSString* response, NSError* error);
typedef void (^QPJSONSResponseCallback)(id response, NSError* error);

@interface PQHttpRequest : NSObject <NSURLConnectionDelegate>{
    NSMutableData* _responseData;
}

+ (NSData*)encodeDictionary:(NSDictionary*)dictionary;
+ (void) getFromURL:(NSURL*)url response:(QPResponseCallback)callback;
+ (void) postToURL:(NSURL*)url withData:(NSDictionary*)data response:(QPResponseCallback)callback;
+ (void) putToURL:(NSURL*)url withData:(NSDictionary*)data response:(QPResponseCallback)callback;
+ (void) getJSONFromURL:(NSURL*)url response:(QPJSONSResponseCallback)callback;
+ (void) postJSONToURL:(NSURL*)url withData:(NSDictionary*)data response:(QPJSONSResponseCallback)callback;
+ (void) basicAuthToURL:(NSURL*)url username:(NSString*)username password:(NSString*)password response:(QPResponseCallback)callback;

@property (nonatomic, assign) BOOL isJsonRequest;
@property (nonatomic, strong) QPResponseCallback callback;
@property (nonatomic, strong) QPJSONSResponseCallback jsonCallback;
@property (nonatomic, strong) NSURLConnection* connection;

@end
